package com.yuexun.dhdoctor.module.personalPlan.model.impl;


import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.module.personalPlan.api.PlanApi;
import com.yuexun.dhdoctor.module.personalPlan.bean.ScheduleData;
import com.yuexun.dhdoctor.module.personalPlan.model.IPlanModel;
import com.yuexun.dhdoctor.util.ApiUtil;

import java.util.List;
import java.util.Map;

import rx.Observable;

/**
 * Created by Administrator on 2017/4/20 0020.
 */

public class PlanModel implements IPlanModel {

    private PlanApi api;

    public PlanApi ApiInstance() {
        if (api != null) {
            return api;
        } else {
            return ApiUtil.getInstance().createRetrofitApi(PlanApi.class);
        }
    }

    @Override
    public Observable<BaseEntity> createSchedule(Map<String, String> praise) {
        api = ApiInstance();
        return api.createSchedule(praise);
    }

    @Override
    public Observable<BaseEntity<Map<String , List<ScheduleData>>>> getScheduleList(Map<String, String> praise) {
        api = ApiInstance();
        return api.getScheduleList(praise);
    }

    @Override
    public Observable<BaseEntity> updateSchedule(Map<String, String> praise) {
        api = ApiInstance();
        return api.updateSchedule(praise);
    }

    @Override
    public Observable<BaseEntity> deleteSchedule(Map<String, String> praise) {
        api = ApiInstance();
        return api.deleteSchedule(praise);
    }
}
